USE Master

GO

IF EXISTS 
(
	SELECT * 
	FROM   master..sysdatabases 
	WHERE  name = N'DynamicMenuDB'
)

DROP DATABASE DynamicMenuDB

GO

CREATE DATABASE DynamicMenuDB

ON PRIMARY
(
	NAME = 'DynamicMenuDB_data',
	FILENAME = 'C:\DynamicMenuDB_data.mdf',
	SIZE = 10mb,
	FILEGROWTH = 10mb
)

GO

USE DynamicMenuDB

GO

CREATE TABLE MenuTable
(
	[ID] int IDENTITY(0, 1) NOT NULL,
	Item VARCHAR(100)  NULL,
	ParentID int REFERENCES MenuTable([ID]) NULL,

	CONSTRAINT PK_ID PRIMARY KEY([ID]),
	--CONSTRAINT PK_UQ UNIQUE (Item)
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'File',
	NULL	
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Edit',
	NULL	
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Help',
	NULL	
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'New',
	0	
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Open',
	0	
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Save',
	0
)

Go

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'-',
	0
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Exit',
	0
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Project',
	3
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'C# Project',
	8
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'VB Project',
	8
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'File Item',
	3
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Class File',
	11
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'DBML File',
	11
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'XML File',
	11
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Cut',
	1
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Copy',
	1
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Paste',
	1
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'-',
	1
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Undo',
	1
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'Redo',
	1
)

GO

INSERT INTO MenuTable
(
	Item,
	ParentID
)
VALUES
(
	'About',
	2
)

GO